#include"SList.h"
void test1()
{
	int datas[] = { 1,3,4,5,6,7,8,19,19 };
	SLLNode* pSLL=CreateSLL(9, datas);
	SLLPrint(pSLL);
}
void test2()
{
	
	
	SLLNode* pSLL = NULL;
	SLLPushBack(&pSLL, 100);
	SLLPrint(pSLL);
	SLLPushBack(&pSLL, 30);
	SLLPrint(pSLL);
	SLLPushBack(&pSLL, 140);
	SLLPrint(pSLL);

	SLLPopBack(&pSLL);
	SLLPrint(pSLL);
	SLLPopBack(&pSLL);
	SLLPrint(pSLL);
	SLLPopBack(&pSLL);
	SLLPrint(pSLL);
	SLLPopBack(&pSLL);
	SLLPrint(pSLL);
	SLLPopBack(&pSLL);
	SLLPrint(pSLL);



	SLLPushFront(&pSLL, 99);
	SLLPrint(pSLL);
	SLLPushFront(&pSLL, 99);
	SLLPrint(pSLL);

	SLLPopFront(&pSLL);
	SLLPrint(pSLL);
	SLLPopFront(&pSLL);
	SLLPrint(pSLL);
	SLLPopFront(&pSLL);
	SLLPrint(pSLL);
	SLLPopFront(&pSLL);
	SLLPrint(pSLL);
}
void test3()
{


	SLLNode* pSLL = NULL;
	SLLPushBack(&pSLL, 100);
	SLLPrint(pSLL);
	SLLPushBack(&pSLL, 30);
	SLLPrint(pSLL);
	SLLPushBack(&pSLL, 140);
	SLLPrint(pSLL);

	


	SLLPushFront(&pSLL, 99);
	SLLPrint(pSLL);
	SLLPushFront(&pSLL, 100);
	SLLPrint(pSLL);

	printf("%p ", SLLFind(pSLL, 99));
	printf("%p ", SLLFind(pSLL, 29));

	printf("%d ", SLLFind(pSLL, 99)->data);
	printf("%d ", SLLFind(pSLL, 99)->next->data);


	SLLInsertAfter(SLLFind(pSLL, 99), -12);
	SLLPrint(pSLL);

	
	SLLInsertAfter(SLLFind(pSLL, -12), -12);
	SLLPrint(pSLL);

	SLLInsertAfter(SLLFind(pSLL, 39), -12);
	SLLPrint(pSLL);

	printf("______\n");
	SLLInsertBefore(&pSLL, SLLFind(pSLL, 100), 77);
	SLLPrint(pSLL);

	SLLInsertBefore(&pSLL, SLLFind(pSLL, 30), 29);
	SLLPrint(pSLL);

	SLLInsertBefore(&pSLL, SLLFind(pSLL, 99), 88);
	SLLPrint(pSLL);

	SLLInsertBefore(&pSLL, NULL, 77);
	SLLPrint(pSLL);

}


void test4()
{


	SLLNode* pSLL = NULL;
	SLLPushBack(&pSLL, 100);
	SLLPrint(pSLL);
	SLLPushBack(&pSLL, 30);
	SLLPrint(pSLL);
	SLLPushBack(&pSLL, 140);
	SLLPrint(pSLL);

	SLLPushFront(&pSLL, 99);
	SLLPrint(pSLL);
	SLLPushFront(&pSLL, 100);
	SLLPrint(pSLL);

	SLLInsertBefore(&pSLL, SLLFind(pSLL, 30), 29);
	SLLPrint(pSLL);

	SLLInsertBefore(&pSLL, SLLFind(pSLL, 99), 88);
	SLLPrint(pSLL);

	SLLEraseAfter( SLLFind(pSLL, 140));
	SLLPrint(pSLL);

	SLLEraseAfter(SLLFind(pSLL, 100));
	SLLPrint(pSLL);

	SLLEraseAfter(SLLFind(pSLL, 29));
	SLLPrint(pSLL);

	SLLErase(&pSLL, SLLFind(pSLL, 99));
	SLLPrint(pSLL);
	SLLErase(&pSLL, SLLFind(pSLL, 29));
	SLLPrint(pSLL);

	SLLErase(&pSLL, SLLFind(pSLL, 100));
	SLLPrint(pSLL);
	SLLErase(&pSLL, SLLFind(pSLL, 100));
	SLLPrint(pSLL);
	SLLErase(&pSLL, SLLFind(pSLL, 140));
	SLLPrint(pSLL);
	SLLErase(&pSLL, SLLFind(pSLL, 29));
	SLLPrint(pSLL);

	printf("-------------\n");
	SListDestroy(&pSLL);
	SLLPrint(pSLL);

}


int main()
{
	//test1();
	/*test2();
	test3();*/
	test4();
	return 0;
}